<?php
/**
 *      [迷你云] (C)2009-2012 南京恒为网络科技.
 *   软件仅供研究与学习使用，如需商用，请访问www.miniyun.cn获得授权
 * 
 */
?>
<?php

class RegisterViewForm extends OptionViewForm
{

    public  $registerStatus;
    public  $findPasswordStatus;
    public  $registerUrl;
    public  $findPasswordUrl;

    
    public function rules()
    {
        $valid = array(
        array('registerStatus, findPasswordStatus', 'required'),
        array('registerUrl', 'judgeRegisterUrl'),
        array('findPasswordUrl', 'judgeFindPasswordUrl'),
        );
        return $valid;
    }


    
    public function judge_user_space(){
        if(!$this->hasErrors())
        {
            $pattern = "^[1-9]\d{0,}M";
            if(!preg_match("/($pattern)/i",$this->default_user_space)){
                $this->addError('default_user_space','格式不正确. 空间格式必须为, 如:10M');
            }
        }
    }

    
    public function judgeRegisterUrl($attribute,$params)
    {
        if(!$this->hasErrors())
        {
            if ($this->registerStatus == 1){
                $prefix = substr(trim($this->registerUrl), 0, 4);
                if(strcasecmp($prefix,   "http") !=  0){
                    $this->addError('registerUrl','注册地址格式不正确.');
                }
            }
        }
    }

    
    public function judgeFindPasswordUrl($attribute,$params)
    {
        if(!$this->hasErrors())
        {
            if ($this->findPasswordStatus == 1){
                $prefix = substr(trim($this->findPasswordUrl), 0, 4);
                if(strcasecmp($prefix,   "http") !=  0){
                    $this->addError('findPasswordUrl','找回密码格式不正确.');
                }
            }
        }
    }

    
    public function attributeLabels()
    {         return  array(
            'registerStatus'=>'是否可以注册',
            'findPasswordStatus'=>'是否可以找回密码',
            'registerUrl'=>'注册地址',
            'findPasswordUrl'=>'找回密码地址',
        );
    }
}